/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.event.thuoc;

import gui.event.ulti.Util;
import gui.thuoc.ThuocChiTiet_Dialog;
import gui.thuoc.ThuocSuaThongTin_Full;
import gui.thuoc.ThuocThem_Full;
import java.awt.print.PrinterException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import model.dao.thuoc.ThuocDAO;

/**
 *
 * @author nv_ca@live.com
 */
public class ThuocMainPanel_evt {

    public static final void btnThemActionPerformed() {
        ThuocThem_Full thuocThem_Full = new ThuocThem_Full(null, true);
        thuocThem_Full.setLocationRelativeTo(null);
        thuocThem_Full.setVisible(true);
    }

    public static final void btnSuaActionPerformed(JTable jTable) {
        int thuocMa = (int) jTable.getValueAt(jTable.getSelectedRow(), 0);
        ThuocSuaThongTin_Full thuocSuaThongTin_Full = new ThuocSuaThongTin_Full(null, true, ThuocDAO.loadByThuocID(thuocMa).get(0));
        thuocSuaThongTin_Full.setLocationRelativeTo(null);
        thuocSuaThongTin_Full.setVisible(true);
    }

    public static final void btnInActionPerformed(JTable table) {
        try {
            table.print();
        } catch (PrinterException ex) {
            Logger.getLogger(ThuocMainPanel_evt.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static final void btnChiTietActionPerformed(JTable jTable) {
        int thuocMa = (int) jTable.getValueAt(jTable.getSelectedRow(), 0);
        ThuocChiTiet_Dialog thuocChiTiet_Dialog = new ThuocChiTiet_Dialog(null, true, ThuocDAO.loadByThuocID(thuocMa).get(0));
        thuocChiTiet_Dialog.setLocationRelativeTo(null);
        thuocChiTiet_Dialog.setVisible(true);
    }

    public static final void btnCloseActionPerformed(JPanel pnl, JTabbedPane jTabbedPane) {
        Util.closeATab(pnl.getName(), jTabbedPane);
    }

    public static final void btnLietKeActionPerformed() {
        //TODO need DAO code here.
//        JOptionPane.showMessageDialog(null, "Can't access DB.");
    }
}
